using System;
using UnityEngine;

public class MarketCategoryButton : MarketButton
{
	public GameObject saleLabel;

	private void OnEnable()
	{
		MarketBuyButton.OnSuccessedBuy = (Action)Delegate.Combine(MarketBuyButton.OnSuccessedBuy, new Action(SetSaleLabel));
	}

	private void OnDisable()
	{
		MarketBuyButton.OnSuccessedBuy = (Action)Delegate.Remove(MarketBuyButton.OnSuccessedBuy, new Action(SetSaleLabel));
	}

	public override void OnClick()
	{
		base.OnClick();
		MarketControllerUI.instance.categoriesPanel.Select(id);
		SetSaleLabel();
	}

	public override void Init(string id, MarketPanel parentPanel)
	{
		base.Init(id, parentPanel);
		SetIcon();
		SetSaleLabel();
	}

	public override void SetIcon()
	{
		base.SetIcon();
		if (id.ToUpper().Equals("Best".ToUpper()) && MarketSaleController.instance.EnableSalesInMarket)
		{
			icon.spriteName = "SaleShop";
		}
	}

	private void SetSaleLabel()
	{
		if (!(saleLabel == null))
		{
			if (id.ToUpper().Equals("Best".ToUpper()) && MarketSaleController.instance.EnableSalesInMarket)
			{
				saleLabel.SetActive(true);
			}
			else
			{
				saleLabel.SetActive(false);
			}
		}
	}
}
